<template>
  <div class="user-info">
    <div class="message">
      <samp class="soccer"> <i class="el-icon-soccer"></i></samp>
      <samp class="football"><i class="el-icon-football"></i></samp>
      <samp class="basketball"><i class="el-icon-basketball"></i></samp>
    </div>
    <el-dropdown>
      <span class="el-dropdown-link">
        <el-avatar
          size="small"
          src="https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png"
        ></el-avatar>
        <span class="zhang">{{ name }}</span>
      </span>
      <template #dropdown>
        <el-dropdown-menu>
          <el-dropdown-item icon="el-icon-circle-close" @click="quit"
            >退出登录</el-dropdown-item
          >
        </el-dropdown-menu>
      </template>
    </el-dropdown>
  </div>
</template>

<script lang="ts">
import { defineComponent, computed } from 'vue'
import { useStore } from '@/store'
import router from '@/router'
import LocalCache from '@/utils/cache'

export default defineComponent({
  setup() {
    const store = useStore()
    const name = computed(() => store.state.loginModule.userInofo.name)
    const quit = () => {
      LocalCache.clearCache()
      router.push({
        path: '/login'
      })
    }

    return {
      name,
      quit
    }
  }
})
</script>

<style scoped lang="less">
.el-dropdown-link {
  cursor: pointer;
  display: flex;
  align-items: center;
}
.zhang {
  margin-left: 10px;
}
.message {
  cursor: pointer;
  font-size: 23px;
  position: absolute;
  right: 160px;
  margin: auto;
  .football {
    margin: 0 10px;
  }
}
</style>
